from datetime import datetime
from typing import List

"""
    分科检查结论词列表
"""


class SignWordDetailList:
    valueOperFemale: str
    spellCode: str
    conclusionWordId: str
    valueOper: str
    severeDegree: int
    generalInspectAdvice: str
    inBriefSummary: int
    mutualExclusiveGroup: str
    signWordDetailDescribe: str
    isDefault: int
    signWordDetailId: int
    isImportAnomaly: int
    valueOperMale: str
    signWordDetail: str
    conclusionWord: str
    signWordId: int

    def __init__(self, valueOperFemale: str, spellCode: str, conclusionWordId: str, valueOper: str, severeDegree: int,
                 generalInspectAdvice: str, inBriefSummary: int,
                 mutualExclusiveGroup: str, signWordDetailDescribe: str, isDefault: int, signWordDetailId: int,
                 isImportAnomaly: int, valueOperMale: str, signWordDetail: str,
                 conclusionWord: str, signWordId: int) -> None:
        self.valueOperFemale = valueOperFemale
        self.spellCode = spellCode
        self.conclusionWordId = conclusionWordId
        self.valueOper = valueOper
        self.severeDegree = severeDegree
        self.generalInspectAdvice = generalInspectAdvice
        self.inBriefSummary = inBriefSummary
        self.mutualExclusiveGroup = mutualExclusiveGroup
        self.signWordDetailDescribe = signWordDetailDescribe
        self.isDefault = isDefault
        self.signWordDetailId = signWordDetailId
        self.isImportAnomaly = isImportAnomaly
        self.valueOperMale = valueOperMale
        self.signWordDetail = signWordDetail
        self.conclusionWord = conclusionWord
        self.signWordId = signWordId


def json2SignWordDetailList(data):
    return SignWordDetailList(data['valueOperFemale'], data['spellCode'], data['conclusionWordId'], data['valueOper'],
                              data['severeDegree'],
                              data['generalInspectAdvice'], data['inBriefSummary'],
                              data['mutualExclusiveGroup'], data['signWordDetailDescribe'], data['isDefault'],
                              data['signWordDetailId'],
                              data['isImportAnomaly'], data['valueOperMale'], data['signWordDetail'],
                              data['conclusionWord'], data['signWordId'])


class SignWordList:
    signWordDetailList: List[SignWordDetailList]
    spellCode: str
    validFlag: int
    isApplyRange: int
    checkItemType: str
    isAutoCompute: int
    shortSignWord: str
    itemName: str
    columnNumber: int
    isReportOut: int
    expression: str
    signWordCode: str
    isOnlyNumber: int
    dataType: int
    signWord: str
    signWordEn: str
    isMultipleChoice: int
    inBriefSummary: int
    itemId: int
    isTitle: int
    decimalDigit: int
    suitGender: int
    signWordId: int

    def __init__(self, signWordDetailList: List[SignWordDetailList],
                 spellCode: str,
                 validFlag: int,
                 isApplyRange: int,
                 checkItemType: str,
                 isAutoCompute: int,
                 shortSignWord: str,
                 itemName: str,
                 columnNumber: int,
                 isReportOut: int,
                 expression: str,
                 signWordCode: str,
                 isOnlyNumber: int,
                 dataType: int,
                 signWord: str,
                 signWordEn: str,
                 isMultipleChoice: int,
                 inBriefSummary: int,
                 itemId: int,
                 isTitle: int,
                 decimalDigit: int,
                 suitGender: int,
                 signWordId: int) -> None:
        self.signWordDetailList = signWordDetailList
        self.spellCode = spellCode
        self.validFlag = validFlag
        self.isApplyRange = isApplyRange
        self.checkItemType = checkItemType
        self.isAutoCompute = isAutoCompute
        self.shortSignWord = shortSignWord
        self.itemName = itemName
        self.columnNumber = columnNumber
        self.isReportOut = isReportOut
        self.expression = expression
        self.signWordCode = signWordCode
        self.isOnlyNumber = isOnlyNumber
        self.dataType = dataType
        self.signWord = signWord
        self.signWordEn = signWordEn
        self.isMultipleChoice = isMultipleChoice
        self.inBriefSummary = inBriefSummary
        self.itemId = itemId
        self.isTitle = isTitle
        self.decimalDigit = decimalDigit
        self.suitGender = suitGender
        self.signWordId = signWordId


def json2SignWordList(data):
    return SignWordList(list(map(lambda x: json2SignWordDetailList(x), data['signWordDetailList'])) if data[
        'signWordDetailList'] else [], data['spellCode'], data['validFlag'], data['isApplyRange'],
                        data['checkItemType'], data['isAutoCompute'], data['shortSignWord'], data['itemName'],
                        data['columnNumber'], data['isReportOut'], data['expression'], data['signWordCode'],
                        data['isOnlyNumber'], data['dataType'], data['signWord'], data['signWordEn'],
                        data['isMultipleChoice'], data['inBriefSummary'], data['itemId'], data['isTitle'],
                        data['decimalDigit'], data['suitGender'], data['signWordId'])


class CheckSignWord:
    deptName: str
    itemType: int
    patientCheckId: str
    itemCode: int
    deptId: int
    registNo: int
    itemCount: int
    itemId: int
    itemName: str
    signWordList: List[SignWordList]
    delayType: int
    applyNo: str
    deptCode: int
    checkItemStatus: int

    def __init__(self, deptName: str, itemType: int, patientCheckId: str,
                 itemCode: int, deptId: int, discount: int, isCombo: int,
                 registNo: int, itemCount: int, itemId: int, itemName: str,
                 signWordList: List[SignWordList],
                 deptCode: int, checkItemStatus: int) -> None:
        self.deptName = deptName
        self.itemType = itemType
        self.patientCheckId = patientCheckId
        self.itemCode = itemCode
        self.deptId = deptId
        self.discount = discount
        self.isCombo = isCombo
        self.registNo = registNo
        self.itemCount = itemCount
        self.itemId = itemId
        self.itemName = itemName
        self.signWordList = signWordList
        self.deptCode = deptCode
        self.checkItemStatus = checkItemStatus


def json2CheckSignWord(data):
    """
    json转为CheckSignWord实体
    :param data:
    :return:
    """
    return CheckSignWord(data['deptName'], data['itemType'], data['patientCheckId'],
                         data['itemCode'], data['deptId'], data['discount'], data['isCombo'],
                         data['registNo'], data['itemCount'], data['itemId'], data['itemName'],
                         list(map(lambda x: json2SignWordList(x), data['signWordList'])) if data[
                             'signWordList'] else [],
                         data['deptCode'], data['checkItemStatus'])


class CheckSignWordResponse:
    msg: str
    code: int
    data: List[CheckSignWord]


def json2CheckSignWordResponse(data):
    print('json2CheckSignWordResponse', data)
    return CheckSignWordResponse(data['msg'], data['code'],
                                 list(map(lambda x: json2CheckSignWord(x), data['data'])) if data['data'] else [])
